import * as CryptoJS from 'crypto-js'

/**
 * AES 对称加密
 * @return {string} secret 密文
 */
export function encrypt(message: string | CryptoJS.lib.WordArray, key: string | CryptoJS.lib.WordArray) {
  const secret = CryptoJS.AES.encrypt(message, key).toString()
  return secret
}

/**
 * AES 对称解密
 */
export function decrypt(ciphertext: string | CryptoJS.lib.CipherParams, key: string | CryptoJS.lib.WordArray) {
  const word = CryptoJS.AES.decrypt(ciphertext, key).toString(CryptoJS.enc.Utf8)
  return word
}
